﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    var spaceId = $.request("spaceId");
    var siteId = $.request("F_SiteId");
    $(function () {
        $("#F_SpaceId").val(spaceId);
        $("#F_SiteId").val(siteId);
        getItemList();
        if (spaceId) {
            $.ajax({
                url: "/SiteManage/Price/GetFormBySpaceId",
                data: { keyValue: spaceId },
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);
                    console.log(JSON.stringify(data));
                }
            });
        }
    });

    function getItemList() {
        $.ajax({
            url: "/SiteManage/Site/GetItemListJson",
            dataType: "json",
            async: false,
            success: function (data) {
                initControl(data)
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log(XMLHttpRequest);
                console.log(textStatus);
                console.log(errorThrown);
            }
        });
    }
    function initControl(ItemList) {
        var units = ItemList.units;
        for (var i = 0; i < units.length; i++) {
            $("#F_Units").append("<option value='" + units[i].F_ItemCode + "'>" + units[i].F_ItemName + "</option>");
        }
        var reservationWay = ItemList.ReservationWay;
        for (var i = 0; i < reservationWay.length; i++) {
            $("#F_ReservationWay").append("<option value='" + reservationWay[i].F_ItemCode + "'>" + reservationWay[i].F_ItemName + "</option>");
        }
        var PropertyFee = ItemList.PropertyFee;
        for (var i = 0; i < PropertyFee.length; i++) {
            $("#F_PropertyFee").append("<option value='" + PropertyFee[i].F_ItemCode + "'>" + PropertyFee[i].F_ItemName + "</option>");
        }
        var CostWater = ItemList.CostWater;
        for (var i = 0; i < CostWater.length; i++) {
            $("#F_CostWater").append("<option value='" + CostWater[i].F_ItemCode + "'>" + CostWater[i].F_ItemName + "</option>");
        }
        var CostNetwork = ItemList.CostNetwork;
        for (var i = 0; i < CostNetwork.length; i++) {
            $("#F_CostNetwork").append("<option value='" + CostNetwork[i].F_ItemCode + "'>" + CostNetwork[i].F_ItemName + "</option>");
        }
        $("#F_Units").bindSelect();//价格单位
        $("#F_ReservationWay").bindSelect();//预定方式
        $("#F_PropertyFee").bindSelect();//电费
        $("#F_CostWater").bindSelect();//水费
        $("#F_CostNetwork").bindSelect();//网费
        
        $("#F_IsNightPlays").bindSelect();//可否通宵搭建
    }
    function submitForm() {
        if (!$('#form1').formValid()) {
            return false;
        }
        $.submitForm({
            url: "/SiteManage/Price/SubmitForm?keyValue=" + $("#F_Id").val(),
            param: $("#form1").formSerialize(),
            success: function () {
                $.currentWindow().$("#Space_gridList").trigger("reloadGrid");
            }
        })
    }
</script>

<form id="form1">
    <div style="padding-top: 20px; margin-right: 20px;">
        <table class="form">
            <tr>
                <td colspan="6" class="interval">价格信息</td>
            </tr>
            <tr>
                <th class="formTitle">价格名称<span style="color:red">*</span></th>
                <td class="formValue">
                    <input id="F_PriceName" name="F_PriceName" type="text" class="form-control required" placeholder="请录入价格名称" />
                    <input id="F_SpaceId" name="F_SpaceId" type="hidden" />
                    <input id="F_SiteId" name="F_SiteId" type="hidden" />
                    <input id="F_Id" name="F_Id" type="hidden" />
                </td>
                <th class="formTitle">预定方式</th>
                <td class="formValue">
                    <select id="F_ReservationWay" name="F_ReservationWay" class="form-control required"></select>
                </td>
            </tr>
            <tr>
                <th class="formTitle">价格单位<span style="color:red">*</span></th>
                <td class="formValue">
                    <select id="F_Units" name="F_Units" class="form-control required"></select>
                </td>
                <th class="formTitle">超人加收(元/人)</th>
                <td class="formValue">
                    <input id="F_BeyondPersonnel" name="F_BeyondPersonnel" type="number" class="form-control" placeholder="请录入超人加收元人" />
                </td>
                <th class="formTitle">超时加收(元/时)</th>
                <td class="formValue">
                    <input id="F_BeyondTime" name="F_BeyondTime" type="number" class="form-control" placeholder="请录入超时加收元时" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">市场价格<span style="color:red">*</span></th>
                <td class="formValue">
                    <input id="F_MarketPrice" name="F_MarketPrice" type="number" class="form-control required" placeholder="请录入市场价格" />
                </td>
                <th class="formTitle">云space价格<span style="color:red">*</span></th>
                <td class="formValue">
                    <input id="F_YunPrice" name="F_YunPrice" type="number" class="form-control required" placeholder="请录入云space价格" />
                </td>
                <th class="formTitle">场地底价<span style="color:red">*</span></th>
                <td class="formValue">
                    <input id="F_FloorPrice" name="F_FloorPrice" type="number" class="form-control required" placeholder="请录入场地底价" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">搭建日底价</th>
                <td class="formValue">
                    <input id="F_PriceFloorBuild" name="F_PriceFloorBuild" type="number" class="form-control" placeholder="请录入搭建日底价" />
                </td>
                <th class="formTitle">搭建日市场刊例价</th>
                <td class="formValue">
                    <input id="F_PriceMarketBuild" name="F_PriceMarketBuild" type="number" class="form-control" placeholder="请录入搭建日市场刊例价" />
                </td>
                <th class="formTitle">搭建日Yunspace价</th>
                <td class="formValue">
                    <input id="F_PriceBuild" name="F_PriceBuild" type="number" class="form-control" placeholder="请录入搭建日Yunspace价" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">可否通宵搭建</th>
                <td class="formValue">
                    <select id="F_IsNightPlays" name="F_IsNightPlays" class="form-control">
                        <option value="false">否</option>
                        <option value="true">是</option>
                    </select>
                </td>
                <td colspan="4"></td>
            </tr>
            <tr>
                <th class="formTitle">通宵搭建底价</th>
                <td class="formValue">
                    <input id="F_PriceNightFloorBuild" name="F_PriceNightFloorBuild" type="number" class="form-control" placeholder="请录入通宵搭建底价" />
                </td>
                <th class="formTitle">通宵搭建市场刊例价</th>
                <td class="formValue">
                    <input id="F_PriceNightMarketBuild" name="F_PriceNightMarketBuild" type="number" class="form-control" placeholder="请录入通宵搭建市场刊例价" />
                </td>
                <th class="formTitle">通宵搭建Yunspace价</th>
                <td class="formValue">
                    <input id="F_PriceNightBuild" name="F_PriceNightBuild" type="number" class="form-control" placeholder="请录入通宵搭建Yunspace价" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">能耗说明（电费）</th>
                <td class="formValue">
                    <select id="F_PropertyFee" name="F_PropertyFee" class="form-control"></select>
                </td>
                <th class="formTitle">能耗说明（水费）</th>
                <td class="formValue">
                    <select id="F_CostWater" name="F_CostWater" class="form-control"></select>
                </td>
                <th class="formTitle">能耗说明（网费）</th>
                <td class="formValue">
                    <select id="F_CostNetwork" name="F_CostNetwork" class="form-control"></select>
                </td>
            </tr>
        </table>
    </div>
</form>

